﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon;
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using BCDto.OA.WorkflowTemplate.WorkflowTemplateFormCustomDatabaseTableColumn;
using BCTMSRESTful.Configs;
using BCService.Utils;
using BCService.OA.WorkflowTemplate.WorkflowTemplateFormCustomDatabaseTableColumn;

namespace BCTMSRESTful.Controllers.Management.OA.WorkflowTemplate.WorkflowTemplateFormCustomDatabaseTableColumn
{
    /// <summary>
    /// 工作流模板表单自定义数据库表集合列
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class WorkflowTemplateFormCustomDatabaseTableColumnController : ManagementBaseController
    {
        private readonly IWorkflowTemplateFormCustomDatabaseTableColumnService workflowTemplateFormCustomDatabaseTableColumnService;

        public WorkflowTemplateFormCustomDatabaseTableColumnController(IWorkflowTemplateFormCustomDatabaseTableColumnService workflowTemplateFormCustomDatabaseTableColumnService)
        {
            this.workflowTemplateFormCustomDatabaseTableColumnService = workflowTemplateFormCustomDatabaseTableColumnService;
        }

        #region 添加工作流模板表单自定义数据库表集合列
        /// <summary>
        ///  添加工作流模板表单自定义数据库表集合列
        /// </summary>
        /// <param name="requestDto">工作流模板表单自定义数据库表集合列信息</param>
        /// <response code="201">添加工作流模板表单自定义数据库表集合列成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加工作流模板表单自定义数据库表集合列")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableColumnDto), 201)]
        public IActionResult Post(
            [FromBody] WorkflowTemplateFormCustomDatabaseTableColumnRequestDto requestDto)
        {
            var result = this.workflowTemplateFormCustomDatabaseTableColumnService.Add(requestDto);
            return StatusCode((int)HttpStatusCode.Created, result);
        }
        #endregion

        #region 修改工作流模板表单自定义数据库表集合列
        /// <summary>
        ///  修改工作流模板表单自定义数据库表集合列
        /// </summary>
        /// <param name="workflowTemplateFormCustomDatabaseTableColumnId">工作流模板表单自定义数据库表集合列Id</param>
        /// <param name="requestDto">工作流模板表单自定义数据库表集合列信息</param>
        /// <response code="200">修改工作流模板表单自定义数据库表集合列成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut("{workflow_template_form_custom_database_table_column_id}")]
        [Log("修改工作流模板表单自定义数据库表集合列")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableColumnDto), 200)]
        public IActionResult Put([FromRoute(Name = "workflow_template_form_custom_database_table_column_id")] long workflowTemplateFormCustomDatabaseTableColumnId, [FromBody] WorkflowTemplateFormCustomDatabaseTableColumnRequestDto requestDto)
        {
            WorkflowTemplateFormCustomDatabaseTableColumnPutDto putDto = requestDto.As<WorkflowTemplateFormCustomDatabaseTableColumnPutDto>();
            putDto.WorkflowTemplateFormCustomDatabaseTableColumnId = workflowTemplateFormCustomDatabaseTableColumnId;
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableColumnService.Update(putDto));
        }
        #endregion

        #region 删除工作流模板表单自定义数据库表集合列
        /// <summary>
        ///  删除工作流模板表单自定义数据库表集合列
        /// </summary>
        /// <param name="workflowTemplateFormCustomDatabaseTableColumnId">工作流模板表单自定义数据库表集合列Id</param>
        /// <response code="204">删除工作流模板表单自定义数据库表集合列成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpDelete("{workflow_template_form_custom_database_table_column_id}")]
        [Log("删除工作流模板表单自定义数据库表集合列")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "workflow_template_form_custom_database_table_column_id")] long workflowTemplateFormCustomDatabaseTableColumnId)
        {
            this.workflowTemplateFormCustomDatabaseTableColumnService.Delete(workflowTemplateFormCustomDatabaseTableColumnId);
            return StatusCode((int)HttpStatusCode.NoContent);
        }
        #endregion

        #region 获取工作流模板表单自定义数据库表集合列
        /// <summary>
        ///  获取工作流模板表单自定义数据库表集合列
        /// </summary>
        /// <param name="workflowTemplateFormCustomDatabaseTableColumnId">工作流模板表单自定义数据库表集合列Id</param>
        /// <response code="200">获取工作流模板表单自定义数据库表集合列</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("{workflow_template_form_custom_database_table_column_id}")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableColumnDto), 200)]
        public IActionResult Get([FromRoute(Name = "workflow_template_form_custom_database_table_column_id")] long workflowTemplateFormCustomDatabaseTableColumnId)
        {
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableColumnService.Get(workflowTemplateFormCustomDatabaseTableColumnId));
        }
        #endregion

        #region 获取工作流模板表单自定义数据库表集合列列表
        /// <summary>
        ///  获取工作流模板表单自定义数据库表集合列列表
        /// </summary>
        /// <param name="formConfigCode">表单配置Code</param>
        /// <response code="200">获取工作流模板表单自定义数据库表集合列列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]/{form_config_code}")]
        [ProducesResponseType(typeof(WorkflowTemplateFormCustomDatabaseTableColumnDto), 200)]
        public IActionResult List([FromRoute(Name = "form_config_code")]string formConfigCode)
        {
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableColumnService.GetList(formConfigCode));
        }
        #endregion

        #region 获取工作流模板表单自定义数据库表集合列（分页）
        /// <summary>
        ///  获取工作流模板表单自定义数据库表集合列（分页）
        /// </summary>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">当前页大小</param>
        /// <response code="200">获取工作流模板表单自定义数据库表集合列（分页）</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WorkflowTemplateFormCustomDatabaseTableColumnDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "start")] DateTime? start,
            [FromQuery(Name = "end")] DateTime? end,
            [FromQuery(Name = "sort_name")] string sortName,
            [FromQuery(Name = "ascending")] bool? ascending,
            [FromQuery(Name = "page_index")] int pageIndex = 1,
            [FromQuery(Name = "page_size")] int pageSize = 10)
        {
            return StatusCode((int)HttpStatusCode.OK, this.workflowTemplateFormCustomDatabaseTableColumnService.Query(start, end, sortName, ascending, pageIndex, pageSize));
        }
        #endregion
    }
}

